package com.study.day20190709;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class CallableTest implements Callable {

    @Override
    public Object call() throws Exception {
        int result=1;
        System.out.println("业务计算");
        Thread.sleep(1000);
        return result;
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CallableTest callableTest=new CallableTest();
        FutureTask<Integer> futureTask=new FutureTask<Integer>(callableTest);

        Thread thread =new Thread(futureTask);
        thread.start();

        System.out.println("别的业务");
        Integer result=futureTask.get();
        System.out.println("结果："+result);
    }
}
